// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import header from './components/common/Header.vue'
import footer from './components/common/Footer.vue'
// import cookie from 'vue-cookie'

Vue.config.productionTip = false


//全局前置路由守卫
//全局前置路由守卫
router.beforeEach((to,from,next) =>{
  if(to.path=="/"||to.path=="/login"||to.path=="/logindx"||to.path=="/loginyx"||to.path=="/goods"||to.path=="/good"){
    next();
  }else{
    var token = window.localStorage.getItem("userS");
    if(token!=""&&token!=null){
      next();
    }else{
      alert("请先登录！！")
      next("/");
    }
  }

})




Vue.component("my-header",header);
Vue.component("my-footer",footer);
Vue.use(ElementUI);
import axios from 'axios'
//设置token信息
// var token = cookie.get("token");
axios.defaults.baseURL="/api/";
// axios.defaults.headers={"token":token}
Vue.prototype.$axios=axios;
// Vue.prototype.$cookie=cookie;
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App},
  template: '<App/>'
})
